package com.qianyitian.hope2.analyzer.service;

import com.qianyitian.hope2.analyzer.analyzer.DemarkAnalyzer;
import com.qianyitian.hope2.analyzer.analyzer.IStockAnalyzer;
import com.qianyitian.hope2.analyzer.config.Constant;
import com.qianyitian.hope2.analyzer.model.*;
import com.qianyitian.hope2.analyzer.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;

public class StockSelecterDemarkResult extends StockSelecter {

    public StockSelecterDemarkResult(List<Stock> symbols, IStockService stockService) {
        super(symbols, stockService);
    }

    DemarkAnalyzer demarkAnalyzer = new DemarkAnalyzer();

    protected void postProcess(ResultInfo resultInfo, Stock stock) {
        if (stock.getkLineType().equals(Constant.TYPE_WEEKLY) || stock.getkLineType().equals(Constant.TYPE_MONTHLY)) {
            //改成daily的
            stock = getStock(stock.getCode(), Constant.TYPE_DAILY_LITE);
        }

        ResultInfo demarkResult = analyze(demarkAnalyzer, stock);
        if (demarkResult != null) {
            //有demark flag
            resultInfo.setData(demarkResult.getData());
        } else {
            //没有demark flag
            Map map = new HashMap<>();
            List<DemarkFlag> list = Collections.EMPTY_LIST;
            map.put("flag", list);
            resultInfo.setData(map);
        }
    }
}
